//
//  FoodDetailsView.m
//  Project----A
//
//  Created by dlios on 15-6-19.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "FoodDetailsView.h"

@implementation FoodDetailsView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame
{self = [super initWithFrame:frame];
    if (self) {
        [self Food];
    }
    return self;
}
-(void)Food
{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-49-64-40)];
    view.backgroundColor = [UIColor blackColor];
    view.alpha = 0.1;
    
#pragma 详情
    self.myimageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-49-64-40)];
    self.myimageview.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.myimageview];
    [self.myimageview addSubview:view];
#pragma 食物名字
    self.englishNamelable = [[UILabel alloc]initWithFrame:CGRectMake(10, 100, 250, 20)];
    self.englishNamelable.backgroundColor = [UIColor clearColor];
    self.englishNamelable.textColor = [UIColor whiteColor];
      [self.englishNamelable setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18]];//加
    [self.myimageview addSubview:self.englishNamelable];
#pragma 食物拼音名字
    self.namelable = [[UILabel alloc]initWithFrame:CGRectMake(10, 75, 250, 20)];
    self.namelable.backgroundColor = [UIColor clearColor];
    self.namelable.textColor = [UIColor whiteColor];
    [self.namelable setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18]];//加
    [self.myimageview addSubview:self.namelable];
#pragma 食物烹饪时间  口味  烹饪方法 功效 适合人群
   
    
    self.cookingway = [[UILabel alloc]initWithFrame:CGRectMake(10, 125, 70, 20)];
    self.cookingway.textColor = [UIColor whiteColor];
    self.cookingway.font = [UIFont systemFontOfSize:15];
    [self.myimageview addSubview:self.cookingway];
    [self.cookingway setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
    
    self.timelength = [[UILabel alloc]initWithFrame:CGRectMake(100, 125, 70, 20)];
    self.timelength.textColor = [UIColor whiteColor];
    self.timelength.font = [UIFont systemFontOfSize:15];
    [self.myimageview addSubview:self.timelength];
    [self.timelength setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
//***
    UILabel *lable1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 150, 70, 20)];
    [lable1 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
    lable1.backgroundColor = [UIColor clearColor];
    lable1.text = @"口味";
    lable1.textColor = [UIColor whiteColor];
 //   lable1.textAlignment = NSTextAlignmentCenter;
    [self.myimageview addSubview:lable1];
//
    self.tastelable = [[UILabel alloc]initWithFrame:CGRectMake(82, 150, 70, 20)];
    self.tastelable.textAlignment = NSTextAlignmentCenter;
    self.tastelable.textColor = [UIColor whiteColor];
    [self.tastelable setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
    [self.myimageview addSubview:self.tastelable];
//    //****
    UILabel *lable2 = [[UILabel alloc]initWithFrame:CGRectMake(10, 175, 70, 20)];
    lable2.backgroundColor = [UIColor clearColor];
    lable2.text = @"烹饪方法";
    [lable2 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
    
    lable2.textColor = [UIColor whiteColor];
    [self.myimageview addSubview:lable2];
//
    self.cookingMethodlable = [[UILabel alloc]initWithFrame:CGRectMake(82, 175, 70, 20)];
    self.cookingMethodlable.textColor = [UIColor whiteColor];
       [_cookingMethodlable setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
    self.cookingMethodlable.textAlignment = NSTextAlignmentCenter;
    [self.myimageview addSubview:self.cookingMethodlable];
//    //******
    UILabel *lable3 = [[UILabel alloc]initWithFrame:CGRectMake(10, 200, 70, 20)];
    lable3.backgroundColor = [UIColor clearColor];
    lable3.text = @"功效";
       [lable3 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
    lable3.textColor = [UIColor whiteColor];
    [self.myimageview addSubview:lable3];

    self.effectlable = [[UILabel alloc]initWithFrame:CGRectMake(100, 200, 70, 20)];
    self.effectlable.textColor = [UIColor whiteColor];
       [_effectlable setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
    [self.myimageview addSubview:self.effectlable];
//    //******
    UILabel *lable4 = [[UILabel alloc]initWithFrame:CGRectMake(10, 225, 70, 20)];
    lable4.backgroundColor = [UIColor clearColor];
    lable4.text = @"适合人群";
    [lable4 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
    lable4.textColor = [UIColor whiteColor];
    [self.myimageview addSubview:lable4];
    self.fittingCrowdlable = [[UILabel alloc]initWithFrame:CGRectMake(100, 225, 150, 20)];
    self.fittingCrowdlable.textColor = [UIColor whiteColor];
    [self.fittingCrowdlable setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加
    [self.myimageview addSubview:self.fittingCrowdlable];
    /*@property(nonatomic,copy)NSString *imagePathLandscape;//食物图片**
     @property(nonatomic,copy)NSString *englishName;//食物名字**
     @property(nonatomic,copy)NSString *effect;//食物对身体的好处**
     @property(nonatomic,copy)NSString *name;//食物名字**
     @property(nonatomic,copy)NSString *fittingRestriction;//原料
     @property(nonatomic,copy)NSString *fittingCrowd; //适合人群
     @property(nonatomic,copy)NSString *cookingMethod ;//煮
     @property(nonatomic,copy)NSString *taste; //口味
     @property(nonatomic,copy)NSString *cookingWay ;//烹饪时间*/
    /*
     @property(nonatomic,retain)UIButton *materialbutton;//材料按钮
     @property(nonatomic,retain)UIButton *methodbutton; //做法按钮
     @property(nonatomic,retain)UIButton *knowledgebutton;//常识按钮
     @property(nonatomic,retain)UIButton *goodAndbadbutton;//相依相克按钮
     @property(nonatomic,retain)UIButton *ViedoMaterialButton;//材料视频按钮
     @property(nonatomic,retain)UIButton *ViedoprocessButton;//制作过程按钮
*/
#pragma 材料按钮
    NSLog(@"!!!!!!!!!%f",HEIGHT/13);
    self.materialbutton = [[UIButton alloc]initWithFrame:CGRectMake(0, self.frame.size.height-104-49, 104*COEFFICIENTW, 40)];
    NSLog(@"%@",NSStringFromCGRect(self.materialbutton.frame));
//    self.materialbutton = [[UIButton alloc]initWithFrame:CGRectMake(0, self.frame.size.height/0.77, self.frame.size.width/3.6, self.frame.size.height/16.7)];
    self.materialbutton.backgroundColor = [UIColor brownColor];
    [self.materialbutton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.materialbutton setTitle:@"" forState:UIControlStateNormal];
    [self.materialbutton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.myimageview.userInteractionEnabled = YES;//打开图片的用户交互
    UIImage *image = [UIImage imageNamed:@"xuancaicailiao.png"];
    [self.materialbutton setImage:image forState:UIControlStateNormal];
    [self addSubview:self.materialbutton];
#pragma 做法按钮
    self.methodbutton = [[UIButton alloc]initWithFrame:CGRectMake(90*COEFFICIENTW, self.frame.size.height-104-49, 104*COEFFICIENTW, 40)];
    self.methodbutton.backgroundColor = [UIColor brownColor];
    [self.methodbutton addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    UIImage *image1 = [UIImage imageNamed:@"zuofa.png"];
    [self.methodbutton setImage:image1 forState:UIControlStateNormal];
    [self.methodbutton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.methodbutton setTitle:@"" forState:UIControlStateNormal];
    [self addSubview:self.methodbutton];
#pragma 常识按钮
    self.knowledgebutton = [[UIButton alloc]initWithFrame:CGRectMake(180*COEFFICIENTW, self.frame.size.height-104-49, 110*COEFFICIENTW, 40)];
    [self.knowledgebutton addTarget:self action:@selector(buttonAct:) forControlEvents:UIControlEventTouchUpInside];
    self.knowledgebutton.backgroundColor = [UIColor brownColor];
    [self.knowledgebutton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    UIImage *image2 = [UIImage imageNamed:@"xuancai.png"];
    [self.knowledgebutton setImage:image2 forState:UIControlStateNormal];
    [self.knowledgebutton setTitle:@"" forState:UIControlStateNormal];
    [self addSubview:self.knowledgebutton];
#pragma  相宜相克按钮
//    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height)];
//    label.backgroundColor = [UIColor redColor];
//    [self addSubview:label];
    self.goodAndbadbutton = [[UIButton alloc]initWithFrame:CGRectMake(280*COEFFICIENTW, self.frame.size.height - 49 - 40 - 64, 108*COEFFICIENTW, 40)];
    NSLog(@"%f",COEFFICIENTW);
    [self.goodAndbadbutton addTarget:self action:@selector(butt:) forControlEvents:UIControlEventTouchUpInside];
    [self.goodAndbadbutton setTitle:@"" forState:UIControlStateNormal];
    [self.goodAndbadbutton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    UIImage *image3 = [UIImage imageNamed:@"xiangshengxiangke.png"];
    [self.goodAndbadbutton setImage:image3 forState:UIControlStateNormal];
    self.goodAndbadbutton.backgroundColor = [UIColor brownColor];
    [self addSubview:self.goodAndbadbutton];
#pragma 材料准备视频
    [self.ViedoMaterialButton = [UIButton alloc]initWithFrame:CGRectMake(0, 0, 110*COEFFICIENTW , 40*COEFFICIENTW)];
    [self.ViedoMaterialButton addTarget:self action:@selector(viedoButton:) forControlEvents:UIControlEventTouchUpInside];
    UIImage *image4 = [UIImage imageNamed:@"cailiaozhunbei.png"];
    [self.ViedoMaterialButton setImage:image4 forState:UIControlStateNormal];
    
    [self.ViedoMaterialButton setTitle:@"" forState:UIControlStateNormal];
    [self.ViedoMaterialButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.ViedoMaterialButton.backgroundColor = [UIColor blueColor];
    [self addSubview:self.ViedoMaterialButton];
#pragma 制作过程视频
    [self.ViedoprocessButton = [UIButton alloc]initWithFrame:CGRectMake(WIDTH-110*COEFFICIENTW, 0, 110*COEFFICIENTW, 40*COEFFICIENTW)];
    [self.ViedoprocessButton addTarget:self action:@selector(domaterbutton:) forControlEvents:UIControlEventTouchUpInside];
    [self.ViedoprocessButton setTitle:@"" forState:UIControlStateNormal];
    [self.ViedoprocessButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.ViedoprocessButton.backgroundColor = [UIColor blueColor];
    UIImage *image5 = [UIImage imageNamed:@"zhizuoguocheng.png"];
   [self.ViedoprocessButton setImage:image5 forState:UIControlStateNormal];
    [self addSubview:self.ViedoprocessButton];
    

}
#pragma 制作过程视频
-(void)domaterbutton:(UIButton *)mater
{
    NSLog(@"制作过程视频");
    [self.mydelegate FoodMater:6];

}
#pragma  材料准备视频
-(void)viedoButton:(UIButton *)viedo
{
    NSLog(@"材料准备视频");
    [self.mydelegate FoodMater:5];

}
#pragma 相宜相克按钮
-(void)butt:(UIButton *)buttonbutton
{
    NSLog(@"相宜相克");
    [self.mydelegate FoodMater:4];
}
#pragma 常识按钮
-(void)buttonAct:(UIButton *)butt
{
    NSLog(@"常识");
    [self.mydelegate FoodMater:3];
}
#pragma 做法按钮
-(void)button:(UIButton *)button1
{
    NSLog(@"做法");
    [self.mydelegate FoodMater:2];
}
#pragma 材料按钮
-(void)buttonAction:(UIButton *)button
{
    [self.mydelegate FoodMater:1];//协议3
    NSLog(@"材料");
}
-(void)setMovie:(Movie *)movie
{
    if (_movie !=movie) {
        [_movie release];
        _movie = [movie retain];
    }
    self.englishNamelable.text = movie.englishName;
    self.namelable.text = movie.name;
    self.cookingway.text = movie.cookingWay;
    
    self.timelength.text = movie.timeLength;
    self.tastelable.text = movie.taste;
    self.effectlable.text = movie.effect;
    
    self.cookingMethodlable.text = movie.cookingMethod;
    self.fittingCrowdlable.text = movie.fittingCrowd;
    NSURL *url = [NSURL URLWithString:movie.imagePathLandscape];
    [self.myimageview sd_setImageWithURL:url];
    
    
     /*@property(nonatomic,copy)NSString *imagePathLandscape;//食物图片**
     @property(nonatomic,copy)NSString *englishName;//食物名字**
     @property(nonatomic,copy)NSString *effect;//食物对身体的好处**
     @property(nonatomic,copy)NSString *name;//食物名字**
     @property(nonatomic,copy)NSString *fittingRestriction;//原料
     @property(nonatomic,copy)NSString *fittingCrowd; //适合人群
     @property(nonatomic,copy)NSString *cookingMethod ;//煮
     @property(nonatomic,copy)NSString *taste; //口味
     @property(nonatomic,copy)NSString *cookingWay ;//烹饪时间*/

}
@end
